﻿using LocationTrackingService.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LocationTrackingService.Model
{
    public class ModelConverter
    {
        public static User convertToModel(UserEntity entity)
        {
            User u = new User();
            u.UserName = entity.username;
            u.Password = entity.password;
            u.Pin = entity.pin;
            return u;
        }
        public static UserEntity convertToEntity(User user)
        {
            UserEntity u = new UserEntity();
            u.username = user.UserName;
            u.password = user.Password;
            u.pin = user.Pin;
            return u;
        }
        public static Location convertToModel(LocationEntity entity)
        {
            Location u = new Location();
            u.UserName = entity.username;
            u.Latitude = entity.latitude;
            u.Longitude = entity.longitude;
            u.ID = entity.id;
            u.Time = Utilities.convertDateToString((DateTime)entity.time);
            return u;
        }
        public static LocationEntity convertToEntity(Location entity)
        {
            LocationEntity u = new LocationEntity();
            u.username = entity.UserName;
            u.latitude = entity.Latitude;
            u.longitude = entity.Longitude;
            u.id = entity.ID;
            u.time = Utilities.convertToTime(entity.Time);
            return u;
        }

    }
}
